<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS练习</title>
    <style type="text/css">
        body {   
	    -moz-user-select:none;   
	} 
        #box{
            border: 1px solid black;
        }
        .caozuo{
            display: inline-block;
            width: 20px;
            height: 20px;
            background: #f9a9a9;
            cursor: pointer;
            color: #0079c1;
            border: none;
            outline: none;
        }
        .gwc{
            height: 20px;
            background: #f9e9a9;
            border: none;
            outline: none;
            cursor: pointer;
        }
        .gwc img{
            vertical-align: middle;
        }
    </style>
	<script type="text/javascript"> 
	<!-- 
	document.oncontextmenu=function(e){return false;} 
	// --></script> 
    <script>
        var money = 30;
        var num = 0;
        window.onload = function () {
            document.getElementById('money').innerHTML = money;
            document.getElementById('num').innerHTML = num;
        }
        function down() {
            money--;
            document.getElementById('money').innerHTML = money;
            if(money<= 20){
                alert('此商品最低出价为20元')
                money = 20;
                document.getElementById('money').innerHTML = money;
            }
        }
        function up() {
            money++;
            document.getElementById('money').innerHTML = money;
            if(money>= 40){
                alert('此商品最高可出价为40元')
                money = 40;
                document.getElementById('money').innerHTML = money;
            }
        }


        function upNum() {
            num++;
            document.getElementById('num').innerHTML = num;
            if(num>=5){
                alert('此商品最多可出价5次   ');
                document.getElementById('num').innerHTML = 5;
            }
        }
    </script>
</head>
<body onselectstart="return false">
<div id="box" align="center">
    <img src="imgs/Box.jpg" alt="">
    <p>
        <button class="caozuo" onclick="down()">-</button>
        <span>￥</span>
        <span id="money"></span>
        <button class="caozuo" onclick="up()">+</button>
        <button class="gwc" onclick="upNum()">点击出价<img src="imgs/gwc.jpg" width="15" height="15" alt=""></button>
        <span>出价</span>
        <span id="num"></span>
        <span>次</span>
        <button id="clear" onclick="num = 0;document.getElementById('num').innerHTML = num;money = 30;document.getElementById('money').innerHTML = money;">重新出价</button>
    </p>
</div>
<script>
window.onkeydown = window.onkeyup = window.onkeypress = function (event) {  
    // 判断是否按下F12，F12键码为123  
    if (event.keyCode = 123) {  
        event.preventDefault(); // 阻止默认事件行为  
        window.event.returnValue = false;  
    }  
}  
// 为右键添加自定义事件，可以禁用  
window.oncontextmenu = function() {  
    event.preventDefault(); // 阻止默认事件行为  
    return false;  
} 
var threshold = 160; // 打开控制台的宽或高阈值  
// 每秒检查一次,如果打开控制台，则刷新页面
window.setInterval(function() {  
    if (window.outerWidth - window.innerWidth > threshold ||   
    window.outerHeight - window.innerHeight > threshold) {   
        window.location.reload();  
        window.close();
        window.location.href = 'black.html';
    }  
}, 1e3);  
</script>
</body>
</html>
